package com.production.CoursePlatform.service;

import com.production.CoursePlatform.entity.Discussion;
import com.production.CoursePlatform.mapper.DiscussionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscussionService {
    @Autowired
    private DiscussionMapper discussionMapper;

    //创建新的帖子
    public int createDiscussionPost(Discussion discussion) {
        return discussionMapper.insertWithoutDID(discussion);
    }

    //获取对应的课堂号的帖子
    public List<Discussion> getListBYctID(int ct_id){
        System.out.println(discussionMapper.getPostBYctID(ct_id));
        return discussionMapper.getPostBYctID(ct_id);
    }

    public int incrementLikes(int dID) {
        return discussionMapper.incrementLikes(dID);
    }

    public int incrementComments(int dID) {
        return discussionMapper.incrementComments(dID);
    }

    public int incrementFavorites(int dID) {
        return discussionMapper.incrementFavorites(dID);
    }

    public int deletePost(int dID) {
        return discussionMapper.deleteById(dID);
    }
}
